import 'package:binggo_bomb/demo/demo1.dart';
import 'package:binggo_bomb/page/bomb/BombIndexWidget.dart';
import 'package:binggo_bomb/page/card/CardIndexWidget.dart';
import 'package:binggo_bomb/page/colorCards.dart';
import 'package:binggo_bomb/page/startBomb.dart';
import 'package:binggo_bomb/utils/localStorage.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class IndexPage extends StatefulWidget {
  const IndexPage({super.key});

  @override
  State<IndexPage> createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {

  late PageController _pageController;

  int currentIndex = 0;

  @override
  void initState() {
    super.initState();
    _pageController = PageController(
        initialPage: currentIndex
    );
    // LocalStorage.set<Map>('pinkCards',{'1':[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,]});
    // Map res = LocalStorage.getKey<Map>("pinkCards") as Map;
    //
    // res["2"] = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,];
    // LocalStorage.set<Map>('pinkCards', {});
  }

  @override
  void dispose() {
    _pageController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: buildBody(),
      bottomNavigationBar: BottomNavigationBar(
        items:[
          BottomNavigationBarItem(
              label: "Bomb",icon: Icon(CupertinoIcons.burst_fill),
              backgroundColor: Colors.blueGrey,
              tooltip: "Bomb"
          ),
          BottomNavigationBarItem(
              label: "BingGo券",icon: Icon(Icons.confirmation_num),
              backgroundColor: Colors.lime,
              tooltip: "BingGo券"
          ),

          BottomNavigationBarItem(
              label: "工具",icon: Icon(Icons.build),
              backgroundColor: Colors.lime,
              tooltip: "工具"
          ),

        ],
        type: BottomNavigationBarType.fixed,
        onTap: (v) {
          setState(() {
            currentIndex = v;
          });
          _pageController.jumpToPage(v);
        },
        currentIndex: currentIndex,
      ),
    );
  }



  Widget buildBody() {
    return PageView(
      controller: _pageController,
      physics: NeverScrollableScrollPhysics(),//viewPage禁止左右滑动
      children: [
         BombIndexWidget(),
         CardIndexWidget(),
        DemoOne(),

        // StartBombPage(),

      ],
    );
  }

}
